package com.kedacom.demo.redis.springdataredis.pubsub;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

/**
 * Producer
 * @author luocanfeng
 * @date 2015年9月7日
 */
@Service
public class Producer {

	@Resource
	protected StringRedisTemplate redisTemplate;

	private Logger logger = LoggerFactory.getLogger(getClass());

	public void sendMessage(String channel, String message) {
		redisTemplate.convertAndSend(channel, message);
		logger.debug("Sent message '{}' to channel '{}'.", message, channel);
	}

}
